import request from '@/utils/request'

// 查询聊天用户列表
export function listUser(query) {
  return request({
    url: '/chat/user/list',
    method: 'get',
    params: query
  })
}

// 查询聊天用户详细
export function getUser(id) {
  return request({
    url: '/chat/user/' + id,
    method: 'get'
  })
}
// 根据系统id获取聊天用户详细信息
export function getUserBySystemId(systemId) {
  return request({
    url: '/chat/user/getUserBySystemId?systemId=' + systemId,
    method: 'get'
  })
}

// 新增聊天用户
export function addUser(data) {
  return request({
    url: '/chat/user',
    method: 'post',
    data: data
  })
}

// 修改聊天用户
export function updateUser(data) {
  return request({
    url: '/chat/user',
    method: 'put',
    data: data
  })
}

// 删除聊天用户
export function delUser(id) {
  return request({
    url: '/chat/user/' + id,
    method: 'delete'
  })
}

// 查询聊天用户好友信息
export function getAllUser(id,friendStatus) {
  if (friendStatus==null){
    return request({
      url: '/chat/user/findByFriend?id=' + id,
      method: 'get'
    })
  }
  return request({
    url: '/chat/user/findByFriend?id=' + id+'&friendStatus='+friendStatus,
    method: 'get'
  })
}

// 添加好友
export function addFriendUser(userId,friendId,messageAdd){
  return request({
    url: '/chat/user/addFriend?userId='+userId+'&friendId='+friendId+'&messageAdd='+messageAdd,
    method: 'get'
  })
}
// 修改好友关系
export function modifyFriendUser(userId,friendId,friendStatus){
  return request({
    url: '/chat/user/modifyFriendUser?userId='+userId+'&friendId='+friendId+'&friendStatus='+friendStatus,
    method: 'get'
  })
}
// 删除好友
export function deleteUser(id,userId) {
  return request({
    url: '/chat/user/delete?id=' + id+"&frindId="+userId,
    method: 'get'
  })
}

// 查询聊天数据（按条数查不重复好友id的最后一个的聊天数据,num 获取的条数）
export function getAllchatLastOne(userId,num=10){
  return request({
    url: '/chat/user/getAllchatLastOne?userId='+userId+'&num='+num,
    method: 'get'
  })
}

//查询用户群组
export function getGroupUser(userId){
  return request({
    url: '/chat/user/groupList/'+userId,
    method: 'get'
  })
}

// 查询聊天数据（按条数查不重复好友id的最后一个的聊天数据,num 获取的条数）
export function getFriendMessage(userId,friendId,page=1,size=10){
  return request({
    url: '/chat/user/getFriendMessage?userId='+userId+'&friendId='+friendId+'&size='+size+'&page='+page,
    method: 'get'
  })
}

// 新增群用户
export function  addGroupUser(userId,groupId){
  return request({
    url: '/chat/user/addGroupUser?userId='+userId+'&groupId='+groupId,
    method: 'get'
  })
}

//查询用户群组状态
export function getUserGroup(userId){
  return request({
    url: '/chat/user/userGroupList/'+userId,
    method: 'get'
  })
}

//根据群主查询申请群的用户
export function getGroupUserList(groupId){
  return request({
    url: '/chat/user/groupUserList?groupId='+groupId,
    method: 'get'
  })
}


//群主是否同意用户加入群聊
export function updateGroupUsers(groupId,userId,groupStatus){
  return request({
    url: '/chat/user/updateGroupUsers?groupId='+groupId+'&userId='+userId+'&groupStatus='+groupStatus,
    method: 'get'
  })
}

